package collection.list.LinkList;

import java.util.Collection;
import java.util.LinkedList;

/*
* 用LinkList模拟队列和栈
* */
public class Demo {
    public static void main(String[] args) {
        //
        LinkedList<String> queue = new LinkedList<>();
        //入队：addLast（往尾部加->排队）
        queue.addLast("张三");
        queue.addLast("李四");
        queue.addLast("王五");
        System.out.println(queue);
        //出队
        System.out.println(queue.removeFirst());
        System.out.println(queue.removeFirst());
        System.out.println(queue);



        //栈：先近后出
        LinkedList<String> stack=new LinkedList<>();
        //压栈
        stack.addFirst("1111");
        stack.push("2222");
        stack.push("3333");
        System.out.println(stack);
        //出栈
        System.out.println(stack.removeFirst());
        System.out.println(stack.pop());
        System.out.println(stack.pop());
    }
}
